﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Telerik.WinControls.UI;
using Telerik.WinControls.Enumerations;

namespace QuanLyNhaSach
{
    public partial class frmDanhMucNhomHang : Form
    {
        public frmDanhMucNhomHang()
        {
            InitializeComponent();

        }

        private void frmDM_NhomHang_Load(object sender, EventArgs e)
        {
            this.gv_khachhang.TableElement.BeginUpdate();
            this.gv_khachhang.MasterTemplate.EnableFiltering = true;
            this.gv_khachhang.MasterTemplate.AutoExpandGroups = true;
            this.gv_khachhang.MasterTemplate.AllowAddNewRow = false;
            this.AddSummaries();
            this.gv_khachhang.TableElement.EndUpdate();
            this.gv_khachhang.Columns[0].Width = 300;
        }
        private void AddSummaries()
        {
            GridViewSummaryRowItem item1 = new GridViewSummaryRowItem();
            item1.Add(new GridViewSummaryItem("column1", "Tổng bản ghi: {0}", GridAggregateFunction.Count));
            this.gv_khachhang.MasterTemplate.SummaryRowsTop.Add(item1);
        }

      

        
        private void bt_tim_ToggleStateChanged(object sender, StateChangedEventArgs args)
        {
            if (!(bt_tim.ToggleState == ToggleState.On))
            {
                this.gv_khachhang.EnableFiltering = false;
                this.gv_khachhang.ShowFilteringRow = false;
                bt_tim.Text = "Button Toggled On";
            }
            else
            {
                this.gv_khachhang.EnableFiltering = true;
                this.gv_khachhang.ShowFilteringRow = true;
                bt_tim.Text = "Button Toggled Off";
            }

        }



        private void bt_sua_Click(object sender, EventArgs e)
        {
            if (bt_sua.Text == "Sửa")
            {
                bt_sua.Image = global::QuanLyNhaSach.Properties.Resources.save;
                bt_sua.Text = "Lưu";
            }
            else if (bt_sua.Text == "Lưu")
            {
                bt_sua.Image = global::QuanLyNhaSach.Properties.Resources.repair_new;
                bt_sua.Text = "Sửa";

            }
        }

        private void bt_them_Click(object sender, EventArgs e)
        {
            if (bt_them.Text == "Thêm")
            {
                bt_them.Image = global::QuanLyNhaSach.Properties.Resources.save;
                bt_them.Text = "Lưu";
                gv_khachhang.AllowAddNewRow = true;
            }
            else if (bt_them.Text == "Lưu")
            {
                bt_them.Image = global::QuanLyNhaSach.Properties.Resources._new;
                bt_them.Text = "Thêm";
                gv_khachhang.AllowAddNewRow = false;

            }
        }

        private void bt_thoat_Click(object sender, EventArgs e)
        {
            this.Close();
        }



    }
}
